package com.vanceinfo.ecados.common;

import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class ViewerSortSelectionListener extends SelectionAdapter {
	private boolean flag = true;
	private ViewerSorter asc, desc;
	private StructuredViewer viewer;

	public ViewerSortSelectionListener(StructuredViewer viewer,
			ViewerSorter asc, ViewerSorter desc) {
		this.asc = asc;
		this.desc = desc;
		this.viewer = viewer;
	}

	public void widgetSelected(SelectionEvent e) {
		viewer.setSorter(flag ? asc : desc);
		flag = !flag;
	}
}